import { InputQuestion, QuestionBase, RadioQuestion, SelectQuestion, TimeQuestion } from '@/components/public-template';
import { TextTable } from '@/components/public-template';
import { TableBase } from '@/components/public-template';
import { Api } from '@/config/api/fileAuthority';
import { Api as ApiSystem } from '@/config/api/system';
import { getMenNum } from '@/utils';
class HomeService {
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new InputQuestion({
        key: 'name',
        label: '名称',
        value: null
      }),
      new SelectQuestion({
        key: 'deptIds',
        label: '部门',
        value: [],
        defaultValue: [],
        type: 'tree',
        state: {
          url: ApiSystem.orgTreeData,
          protType: 'post',
          nameKey: 'name',
          nameValue: 'id',
          nameChildren: 'childOrg',
          treeCheckable: true
        }
      }),
      new SelectQuestion({
        key: 'roleIds',
        label: '角色',
        prompt: '请选择',
        // type: 'tree',
        state: {
          mode: 'multiple',
          url: Api.roleList,
          optionFilterProp: 'label',
          protType: 'post',
          nameKey: 'name',
          nameValue: 'id'
          // nameChildren: 'childOrg'
        }
      })
    ];
    return questions;
  }
  getEditQuestions() {
    const questions: QuestionBase<any>[] = [
      new RadioQuestion({
        key: 'dataPermission',
        label: '数据权限',
        value: 1,
        options: [
          {
            label: '全部',
            value: 1
          },
          {
            label: '自定义',
            value: 2
          }
        ],
        state: {
          changeOptions: {
            1: [getMenNum('deptIds', 'hidden', true)],
            2: [getMenNum('deptIds', 'hidden', false)]
          }
        }
      }),
      new SelectQuestion({
        key: 'deptIds',
        label: '部门',
        value: [],
        defaultValue: [],
        type: 'tree',
        state: {
          url: ApiSystem.orgTreeData,
          protType: 'post',
          nameKey: 'name',
          nameValue: 'id',
          nameChildren: 'childOrg',
          treeCheckable: true
        }
      })
    ];
    return questions;
  }
  getTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'num',
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'name',
        value: '名称'
      }),

      new TextTable({
        key: 'deptName',
        value: '部门'
      }),
      new TextTable({
        key: 'roleName',
        value: '角色'
      }),
      new TextTable({
        key: 'perssiomName',
        value: '数据权限'
      }),
      new TextTable({
        key: 'actions',
        value: '操作',
        columns: {
          fixed: 'right',
          width: 120
        },
        handle: [
          {
            type: 'local',
            text: '编辑',
            class: 'text-primary',
            state: {}
            // showKey: [{ key: 'status', value: 0 }]
          }
        ]
      })
    ];
    return tables;
  }
  getIcons() {
    const icons: TableBase<any>[] = [
      new TextTable({
        key: 'local',
        value: '批量编辑',
        type: 'primary',
        class: 'icon-bianji',
        state: {}
      })
    ];
    return icons;
  }
}

export default new HomeService();
